/*
 * Utils.h
 *
 *  Created on: Aug 27, 2017
 *      Author: zjf
 */

#ifndef SRC_UTILS_H_
#define SRC_UTILS_H_

#include <string>

using namespace std;

namespace std
{

std::string str2hex(std::string& str);
void escapeJsonString(std::string& str);
void replaceSubString(std::string & s, std::string const & t, std::string const & w);
std::string joinStrings(std::vector<std::string>& vecString, std::string& strSep);
bool readFileFromZip(const std::string& zipFile, std::string& subFile, std::string& outStr);

inline string& ltrim(string &str, const string& trimChars = " \t\n\r")
{
	str.erase(0, str.find_first_not_of(trimChars));
	return str;
}

inline string& rtrim(string &str, const string& trimChars = " \t\n\r")
{
	str.erase(str.find_last_not_of(trimChars) + 1);
	return str;
}

inline string& trim(string &str, const string& trimChars = " \t\n\r")
{
	ltrim(rtrim(str, trimChars), trimChars);
	return str;
}

}

#endif /* SRC_UTILS_H_ */
